/**
 * @author daniele.gili@usi.ch
 * @author blancsv@usi.ch
 */

package ch.usi.inf.pf2;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;

public class PanicSimFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private PanicSimMain circuit;
	private PanicSimDrawingArea area;
	private JPanel drawingPanel;

	private PanicSimFrameLeftItemBar leftItemBar;
	private PanicSimFrameMenu frameMenu;
	private PanicSimLegendBar legendBar;

	public PanicSimFrame(final PanicSimMain circuit) {
		this.setCircuit(circuit);

		drawingPanel = new JPanel();
		area = new PanicSimDrawingArea(circuit);

		MegaInputDrawer panel2 = new MegaInputDrawer(area);
		MegaOutputDrawer panel3 = new MegaOutputDrawer(area);

		area.giveDrawer(panel2, panel3);
		
		panel2.setBorder(new EtchedBorder());
		panel3.setBorder(new EtchedBorder());

		
		BoxLayout f = new BoxLayout(drawingPanel, BoxLayout.Y_AXIS);
		drawingPanel.setLayout(f);
		
		area.setBorder(new EtchedBorder());


		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setTitle("Drawing");
		setSize(new Dimension(1000, 700));
		
		
		
		frameMenu = new PanicSimFrameMenu(circuit, area);
		add(frameMenu, BorderLayout.NORTH);
		
		leftItemBar = new PanicSimFrameLeftItemBar(circuit, area);
		add(leftItemBar, BorderLayout.WEST);
		
		legendBar = new PanicSimLegendBar(circuit, area);
		add(legendBar, BorderLayout.SOUTH);

		drawingPanel.add(area);
		drawingPanel.add(panel2,BorderLayout.NORTH);
		drawingPanel.add(panel3, BorderLayout.SOUTH);


		
		
		area.setPreferredSize(new Dimension(this.getWidth()-300,this.getHeight() -200));
		add(drawingPanel, BorderLayout.CENTER);
	

	}

	public void setCircuit(PanicSimMain circuit) {
		this.circuit = circuit;
	}

	public PanicSimMain getCircuit() {
		return circuit;
	}

}

// /////////////////////////////////////////////
class MyWindowListener extends WindowAdapter {

	public void windowClosing(WindowEvent e) {

		System.out.println("f");
	}

}